<template>
    <div>
        <div class="Jregister_body_code" :class='yzm?"yzmshow":"yzmhide"' @click='yzmhq'>
			{{yzmtext}}
		</div>
       
    </div>
</template>

<script>
    import { Toast } from 'mint-ui';
    export default {
        data(){
            return{
            	yzm:true,
				yzmtext:'获取验证码',
				yzmtime:60,
				phone:'15395794048',
            }
        },
        watch: {
    		phoneNew(val){
    			
    		},
    	},
        props:[
            'phoneNew'
        ],
        mounted(){
        	
        },
        methods:{
        	yzmdjs(){
				if(this.yzmtime!=0){
					this.yzmtime--;
					this.yzmtext=this.yzmtime+'s';
					setTimeout(()=>{
						this.yzmdjs();
					},1000)
				}
				else{
					this.yzmtime=60;
					this.yzmtext='获取验证码';
					this.yzm=true;
				}
			},
			yzmhq(){
				console.log(this.phoneNew)
				let ph='';
				if(this.phoneNew==undefined||this.phoneNew==''){
					ph=this.phone;
				}
				else{
					ph=this.phoneNew;
				}
				if(this.yzm){
					this.yzm=false;
					this.ajax(this, {
						'url': this.defines.send_code,
						'type': 'post',
						'data':{
							'mobile':ph
						},
						'callback': data => {
							if(data.data.error_code==0) {
								Toast('发送成功');
								this.yzmdjs();
	
							} else {
								this.yzm=true;
								Toast(data.data.error_msg)
							}
	
						},
						'errorback': errory => {
	
						},
	
					})

				}
				
			},
        	
        }
    }
</script>
<style scoped>
	.Jregister_body_code{
		border-radius: 0.4rem;
		padding: 0 1rem;
		background: #000;
		color: #f7bd40;
		font-size: 1.2rem;
		line-height: 3rem;
		height: 3rem;
		margin-left: 1rem;
	}
	.yzmshow{
	}
	.yzmhide{
		color: #fff;
		background: #717171;
	}
	
</style>
